Implicitly converts to T. this must not be in the null state.
Gets the value or the default value passed in.
Forces this to the null state.
Assigns value to the internally-held state. If the assignment succeeds, this becomes non-null.
Gets the value. this must not be in the null state. This function is also called for the implicit conversion to T.
Check if this is in the null state.
struct CustomerRecord { string name; string address; int customerNum; } Nullable!CustomerRecord getByName(string name) { //A bunch of hairy stuff return Nullable!CustomerRecord.init; } auto queryResult = getByName("Doe, John"); if (!queryResult.isNull) { //Process Mr. Doe's customer record auto address = queryResult.address; auto customerNum = queryResult.customerNum; //Do some things with this customer's info } else { //Add the customer to the database }
Defines a value paired with a distinctive "null" state that denotes the absence of a value. If default constructed, a Nullable!T object starts in the null state. Assigning it renders it non-null. Calling nullify can nullify it again. Practically Nullable!T stores a T and a bool.